package cn.zwy.实战;

import cn.zwy.bean.UserBean;

public class TOJSON implements ASMJsonInterface{
    private String username;
    
    private Class<?> targetClass;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
    
    public void convert(Object object){
        UserBean bean = (UserBean) object;
        String name = bean.getUsername();
        System.out.println(name);
    }

    public Class<?> getTargetClass() {
        return targetClass;
    }

    public void setTargetClass(Class<?> targetClass) {
        this.targetClass = targetClass;
    }

    @Override
    public String toJSON(Object object) {
        UserBean userBean = (UserBean) object;
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        sb.append("\"username\"");
        sb.append(":");
        sb.append("\"");
//        sb.append(userBean.getUsername());
        sb.append(String.valueOf(userBean.getAmount()));
        sb.append("\"");
        sb.append("}");
        return sb.toString();
    }
}
